package cn.edu.stu.syllabus.datas;

import android.support.annotation.ColorInt;
import android.support.v4.content.ContextCompat;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.edu.stu.syllabus.application.SyllabusApplication;

/**
 * Created by daidaijie on 2017/3/16.
 */

public class OaCompany {

    private int mId;

    private String mName;

    private String mShortName;

    @ColorInt
    private int mColor;

    public OaCompany() {
    }

    public OaCompany(int id, String name, String shortName) {
        mId = id;
        mName = name;
        mShortName = shortName;
    }

    public int getId() {
        return mId;
    }

    public void setId(int id) {
        mId = id;
    }

    public String getName() {
        return mName;
    }

    public void setName(String name) {
        mName = name;
    }

    public String getShortName() {
        return mShortName;
    }

    public void setShortName(String shortName) {
        mShortName = shortName;
    }

    public int getColor() {
        return mColor;
    }

    public void setColor(int color) {
        mColor = color;
    }

    public static class OaCompaniesHolder {

        private static Map<Integer, OaCompany> sOaCompanyMap;
        private static List<OaCompany> sOaCompanies;

        static {
            sOaCompanyMap = new HashMap<>();
            sOaCompanies = new ArrayList<>();
            sOaCompanies.add(new OaCompany(0, "全部", "全部"));
            sOaCompanies.add(new OaCompany(35, "理学院", "理学院"));
            sOaCompanies.add(new OaCompany(40, "长江新闻学院", "新闻"));
            sOaCompanies.add(new OaCompany(42, "体育部", "体育部"));
            sOaCompanies.add(new OaCompany(44, "网络与信息中心", "网络"));
            sOaCompanies.add(new OaCompany(46, "学报编辑部", "学编部"));
            sOaCompanies.add(new OaCompany(101, "发展规划办", "发规办"));
            sOaCompanies.add(new OaCompany(121, "学生创业中心", "学创"));
            sOaCompanies.add(new OaCompany(207, "弘毅书院", "弘毅"));
            sOaCompanies.add(new OaCompany(26, "财务处", "财务处"));
            sOaCompanies.add(new OaCompany(202, "知行书院", "知行"));
            sOaCompanies.add(new OaCompany(28, "科研处", "科研处"));
            sOaCompanies.add(new OaCompany(32, "继续教育学院", "继教院"));
            sOaCompanies.add(new OaCompany(36, "文学院", "文学院"));
            sOaCompanies.add(new OaCompany(39, "长江艺术学院", "艺术"));
            sOaCompanies.add(new OaCompany(73, "研究生学院负责人", "研负责"));
            sOaCompanies.add(new OaCompany(201, "思源书院", "思源"));
            sOaCompanies.add(new OaCompany(204, "知行书院办公室", "知行办"));
            sOaCompanies.add(new OaCompany(33, "资源管理处", "资管处"));
            sOaCompanies.add(new OaCompany(37, "法学院", "法学院"));
            sOaCompanies.add(new OaCompany(41, "社科部", "社科部"));
            sOaCompanies.add(new OaCompany(43, "图书馆", "图书馆"));
            sOaCompanies.add(new OaCompany(69, "商学院负责人", "商负责"));
            sOaCompanies.add(new OaCompany(50, "宣传部", "宣传部"));
            sOaCompanies.add(new OaCompany(22, "党政办/国际交流处", "党政办"));
            sOaCompanies.add(new OaCompany(25, "人事处", "人事处"));
            sOaCompanies.add(new OaCompany(74, "ELC负责人", "ELC负责"));
            sOaCompanies.add(new OaCompany(141, "教师发展与教育评估中心", "教中心"));
            sOaCompanies.add(new OaCompany(24, "监察审计处", "监审处"));
            sOaCompanies.add(new OaCompany(48, "中心实验室", "中实验"));
            sOaCompanies.add(new OaCompany(71, "新闻学院负责人", "新闻责"));
            sOaCompanies.add(new OaCompany(47, "ELC", "ELC"));
            sOaCompanies.add(new OaCompany(1, "校领导", "校领导"));
            sOaCompanies.add(new OaCompany(38, "商学院", "商学院"));
            sOaCompanies.add(new OaCompany(68, "法学院负责人", "法负责"));
            sOaCompanies.add(new OaCompany(23, "组织统战部", "组统部"));
            sOaCompanies.add(new OaCompany(27, "教务处", "教务处"));
            sOaCompanies.add(new OaCompany(29, "研究生学院", "研究生"));
            sOaCompanies.add(new OaCompany(30, "学生处（团委）", "学生处"));
            sOaCompanies.add(new OaCompany(70, "艺术学院负责人", "艺术责"));
            sOaCompanies.add(new OaCompany(72, "高教所负责人", "高教责"));
            sOaCompanies.add(new OaCompany(181, "汕头大学体育园", "汕体园"));
            sOaCompanies.add(new OaCompany(31, "校工会", "校工会"));
            sOaCompanies.add(new OaCompany(67, "工学院负责人", "工负责"));
            sOaCompanies.add(new OaCompany(34, "工学院", "工学院"));
            sOaCompanies.add(new OaCompany(45, "高等教育研究所", "高教所"));
            sOaCompanies.add(new OaCompany(49, "至诚书院", "至诚"));
            sOaCompanies.add(new OaCompany(61, "基金会", "基金会"));


            // 忽略第一个
            for (int i = 1; i < sOaCompanies.size(); i++) {
                OaCompany oaCompany = sOaCompanies.get(i);
                oaCompany.setColor(ContextCompat.getColor(SyllabusApplication.getContext(),
                        ColorHolder.bgColors[i % ColorHolder.bgColors.length]));
                sOaCompanyMap.put(oaCompany.mId, oaCompany);
            }
        }
    }

    public static OaCompany getOaCompanyById(int id) {
        return OaCompaniesHolder.sOaCompanyMap.get(id);
    }

    public static List<OaCompany> getOaCompanies() {
        return OaCompaniesHolder.sOaCompanies;
    }

    public static String[] getOaCompaniesNameStringArray() {
        String[] names = new String[OaCompaniesHolder.sOaCompanies.size()];
        for (int i = 0; i < OaCompaniesHolder.sOaCompanies.size(); i++) {
            names[i] = OaCompaniesHolder.sOaCompanies.get(i).getName();
        }
        return names;
    }
}
